#include<bits/stdc++.h>
int m[100010][4] , n , x , y;
using namespace std;
int main (){
	freopen("carpet.in" , "r" , stdin);
	freopen("carpet.out" , "w" , stdout);
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> m[i][0] >> m[i][1] >> m[i][2] >> m[i][3];
	}
	cin >> x >> y;
	int flag = 0;
	for(int i = n ; i >= 1 ; i--){
		if(x >= m[i][0] && y >= m[i][1] && x <= m[i][0] + m[i][2] && y <= m[i][1] + m[i][3]){
			flag = 1;
			cout << i << endl;
			break;
		}
	}
	if(flag == 0){
		cout << "-1" << endl;
	}
	return 0;
}